﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Home.Master" AutoEventWireup="true" CodeBehind="ChangeProfile.aspx.cs" Inherits="OnlineAuction.ChangeProfile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function check() {
            var PhoneNumber = document.getElementById('<%=txtPhoneNumber.ClientID%>').value;
            var IdentityCard = document.getElementById('<%=txtIdentityCard.ClientID%>').value;
            var Email = document.getElementById('<%=txtEmail.ClientID%>').value;
            var FullName = document.getElementById('<%=txtFullName.ClientID%>').value;

            if (FullName.length == 0) {
                document.getElementById("ErrorFullName").innerHTML = "Please insert full name";
                return false;
            }
            else {
                document.getElementById("ErrorFullName").innerHTML = "";
                if (checkNumber(PhoneNumber) == false || PhoneNumber.length < 8 || PhoneNumber.length > 13) {
                    document.getElementById("ErrorPhoneNumber").innerHTML = "Length of phone number must be >8 and <13 characters and must be numbers";
                    return false;
                }
                else {
                    document.getElementById("ErrorPhoneNumber").innerHTML = "";
                    if (checkNumber(IdentityCard) == false || IdentityCard.length != 10) {
                        document.getElementById("ErrorIdentityCard").innerHTML = "Length of Identity card is 10 and must be numbers";
                        return false;
                    }
                    else {
                        document.getElementById("ErrorIdentityCard").innerHTML = "";
                        if (checkEmail(Email) == false) {
                            document.getElementById("ErrorEmail").innerHTML = "Email is not valid";
                            return false;
                        }
                    }
                }
            }
            return true;
        }
        function checkEmail(Email) {
            var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            return re.test(Email);
        }
        function checkNumber(n) {
            return !isNaN(parseFloat(n)) && isFinite(n);
        }
        function checkUserName(UserName) {
            var re = /^[a-zA-Z0-9]+$/;
            return re.test(UserName);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <table cellspacing="5" class="style1">
        <caption style="font-size: larger; font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FF6600">Update Profile</caption>
        <tr>
            <td>Full Name: </td>
            <td>
                <asp:TextBox ID="txtFullName" runat="server" Width="300px"></asp:TextBox>
            </td>
            <td>
                <span id="ErrorFullName" style="color: red;"></span>
            </td>
        </tr>
        <tr>
            <td>Gender: </td>
            <td>
                <asp:RadioButtonList ID="rbtGender" runat="server" RepeatDirection="Horizontal" Width="300px">
                    <asp:ListItem Value="1">Male</asp:ListItem>
                    <asp:ListItem Value="0">Female</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td>Phone Number: </td>
            <td>
                <asp:TextBox ID="txtPhoneNumber" runat="server" Width="300px"></asp:TextBox>
            </td>
            <td>
                <span id="ErrorPhoneNumber" style="color: red;"></span>
            </td>
        </tr>
        <tr>
            <td>Identity Card: </td>
            <td>
                <asp:TextBox ID="txtIdentityCard" runat="server" Width="300px"></asp:TextBox>
            </td>
            <td>
                <span id="ErrorIdentityCard" style="color: red;"></span>
            </td>
        </tr>
        <tr>
            <td>Email: </td>
            <td>
                <asp:TextBox ID="txtEmail" runat="server" Width="300px"></asp:TextBox>
            </td>
            <td>
                <span id="ErrorEmail" style="color: red;"></span>
            </td>
        </tr>
        <tr>
            <td>Address: </td>
            <td colspan="2">
                <asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" Width="423px" Height="150px" />
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td colspan="2">
                <asp:Button ID="btnAddUser" runat="server" Text="Update Profile" OnClick="btnAddUser_Click" OnClientClick="return check()" />
                <asp:Button ID="btnReset" runat="server" Text="Reset" OnClick="btnReset_Click" />
            </td>
        </tr>
    </table>
</asp:Content>
